﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Benlai.Model.Doc;
using Benlai.Dac.Mongo;
using MongoDB.Driver;

namespace Benlai.Dac.Doc
{
    public class InterfaceDocDac : MongoHandler<InterfaceDocModel>
    {
        public InterfaceDocDac()
        {
            DBName = "houtai";
            Name = "InterfaceDoc";
            SortPropertyName = "No";
            IsDescending = false;
        }

        public InterfaceDocModel GetByID(string id)
        {
            return FindByID(id);
        }

        public List<InterfaceDocModel> Get(string no)
        {
            return GetModel(new { No = no }).ToList<InterfaceDocModel>();
        }

        public List<InterfaceDocModel> GetByName(string name)
        {
            return GetModel(new { IName = name }).ToList<InterfaceDocModel>();
        }

        public void Set(InterfaceDocModel model)
        {
            if (string.IsNullOrEmpty(model.Id))
            {
                Insert(model);
            }
            else
            {
                Update(model, model.Id);
            }
        }
        
        public List<InterfaceDocModel> GetList(int pageIndex, int pageSize, out int recordCount)
        {
            return GetModel(pageIndex, pageSize, out recordCount).ToList<InterfaceDocModel>();
        }
    }
}
